<template>
  <div class="margin_top">
    <div class="top_reserve">
      <div class="tit">产品预定</div>
    </div>
    <div class="reserve_box">
      <a-table
        :columns="reservecolumns"
        :pagination="pagination"
        :dataSource="reservedata"
        bordered
      >
       
        <template slot="down" slot-scope="text, record, index">
          <div class="down_box">
            <span class="del">
              <a :href="record.annex" target="view_frame">下载<a-icon class="ico" type="cloud-download" /></a>
              
            </span>
          </div>
        </template>
        <template slot="operation" slot-scope="text, record, index">
          <span class="del" @click="deleter(record.key)">删除</span>
        </template>
      </a-table>
    </div>
  </div>
</template>

<script>
import qs from "qs";
const reservecolumns = [
  {
    title: "姓名",
    dataIndex: "username",
    scopedSlots: { customRender: "username" }
  },
  {
    title: "联系电话",
    dataIndex: "phone",
    scopedSlots: { customRender: "phone" }
  },
  {
    title: "公司名称",
    dataIndex: "companyName",
    scopedSlots: { customRender: "companyName" }
  },
  {
    title: "内容",
    dataIndex: "down",
    scopedSlots: { customRender: "down" }
  },
  {
    title: "提交时间",
    dataIndex: "dateline",
    scopedSlots: { customRender: "dateline" }
  },
  {
    title: "操作",
    dataIndex: "operation",
    scopedSlots: { customRender: "operation" }
  }
];
const reservedata = [];

for (let i = 0; i < 20; i++) {
  // data.push({
  //   key: i.toString(),
  //   xse: "大于5000",
  //   tcbl: "5%"
  // });
  //   reservedata.push({
  //     key: i.toString(),
  //     id_num: i,
  //     username: "王圣磊",
  //     qy: "陕西西安",
  //     fl: "2020-3-31",
  //     down: "下载"
  //   });
}
export default {
  data() {
    return {
      reservedata,
      reservecolumns,
      pagination: {
        defaultPageSize: 10,
        showTotal: total => `共 ${total} 条数据`,
        total: 0
      }
    };
  },

  methods: {
    getcpydlist(pagination) {
      this.axios
        .post(
          "fhl/xunjia/productDzList.php",
          qs.stringify({
            page: pagination.current,
            pageSize: pagination.defaultPageSize,
            sqdwid: this.$store.state.bbl_sqdwid,
            type :1

          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 303) {
            this.pagination.total = Number(res.data.result.total);
            this.reservedata = res.data.result.data;
            for (var i = 0; i < this.reservedata.length; i++) {
              this.reservedata[i].key = this.reservedata[i].id_num;
            }
          }
        });
    },
    deleter(key) {
      this.axios
        .post(
          "fhl/xunjia/productDzDelete.php",
          qs.stringify({
            id_num: key
          })
        )
        .then(res => {
          if (res.data.code == 303) {
            this.getcpydlist(this.pagination);
            this.$notification["success"]({
              message: "成功",
              description: res.data.msg
            });
          } else {
            this.$notification["error"]({
              message: "失败",
              description: res.data.msg
            });
          }
        });
    },
   
  },

  created() {
    this.getcpydlist(this.pagination);
  }
};
</script>

<style lang='less'>
.margin_top {
  width: 98%;
  margin: 67px auto;
  background: #fff;
  padding: 22px;
  .top_reserve {
    text-align: left;
    font-weight: bold;
    font-size: 18px;
    color: #333;
  }
  .top_reserve {
    padding: 10px;
  }
  .reserve_box {
    .down_box {
      .ico {
        font-size: 20px;
        margin-left: 5px;
        vertical-align: middle;
      }
    }
  }
}
</style>
